package com.tejava.cafe_in;

import java.util.ArrayList;

import com.tejava.DB.History;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

public class HistoryAdapter extends ArrayAdapter<Object>{
private ArrayList<History> data;
	
	View v;
	ImageView image;
	
	public HistoryAdapter(Context context, int textViewResourceId,
			ArrayList items){
		super(context, textViewResourceId, items);
		this.data = items;
	}

		public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
			
			v=convertView;
			
			if( v == null)
			{
				LayoutInflater vi=(LayoutInflater)getContext().getSystemService(
						Context.LAYOUT_INFLATER_SERVICE);
				v= vi.inflate(R.layout.list_layout_text, null);
			}
			
			History item=data.get(position);
			if(item != null)
			{
			//	image=(ImageView)v.findViewById(R.id.image);
				
				TextView v_name=(TextView)v.findViewById(R.id.historyName);
				TextView v_date=(TextView)v.findViewById(R.id.historyDate);
			
								
				v_name.setText(item.getName());
				v_date.setText(item.getDate());			

			}
			
			
			return v;
		}
}
